import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { EquipRefreshRateInfo } from "./info/EquipRefreshRateInfo";
import { ItemData } from "./info/ItemData";
import { ECategory } from "../../../Message/Public/ECategory";
import { EEquip } from "../../../Message/Public/EEquip";
import { Cache } from "../cache/Cache";
type int = number;
//class EquipConfig
    
    export  class EquipConfig
    {
        constructor()
        {
            
            this._equipConfigDic = new Map<any, any> /* flash.utils.Dictionary */();
            this._refreshRateDic = new Map<any, any> /* flash.utils.Dictionary */();
            if (EquipConfig._instance != null) 
            {
                throw new Error(" EquipConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("equipConfig.xml");
            this.writeConfigs(loc1.root);
            loc1 = ConfigManager.instance.getJSONByFileName("t_equip_refresh_rate.json");
            this.writeRefreshRateConfig(loc1);
            return;
        }

        /* internal  */writeConfigs(arg1: Object): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=arg1.items as Array<any>;
            var loc4=0;
            var loc5=loc1;
            for(loc2 of loc5) 
            {
                loc3 = loc2.type.toString();
                this._equipConfigDic[loc3] = loc2;
            }
            return;
        }

        /* internal  */writeRefreshRateConfig(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc1 of loc4) 
            {
                loc2 = new EquipRefreshRateInfo();
                loc2.initData(loc1);
                this._refreshRateDic[loc2.id] = loc2;
            }
            return;
        }

        public getRefreshTargetCbData(arg1: int): Array<any>
        {
            return this._equipConfigDic["refreshTargetCb" + arg1].item as Array<any>;
        }

        public checkHasRate(arg1: ItemData, arg2: int): Boolean
        {
            var loc1=0;
            var loc2=null;
            if (arg1.category == ECategory._ECategoryEquip && (arg1.type == EEquip._EEquipFashion || arg1.type == EEquip._EEquipWing || arg1.type == EEquip._EEquipFootPrint || arg1.type == EEquip._EEquipBubble || arg1.type == EEquip._EEquipSurround || arg1.type == EEquip._EEquipWaistBelt || arg1.type == EEquip._EEquipElf)) 
            {
                loc1 = Cache.instance.role.roleInfo.career;
            }
            else if (arg1.category != ECategory._ECategoryPetEquip) 
            {
                loc1 = arg1.itemInfo.item.career;
            }
            else 
            {
                loc1 = arg1.itemInfo.item.effectEx;
            }
            var loc3=0;
            var loc4=this._refreshRateDic;
            for(loc2 of loc4) 
            {
                if (!(loc2 && loc2.career & loc1 && loc2.category == arg1.category && loc2.type == arg1.type)) 
                {
                    continue;
                }
                return loc2.hasRate(arg2);
            }
            return false;
        }

        public static get instance(): EquipConfig
        {
            if (EquipConfig._instance == null) 
            {
                EquipConfig._instance = new EquipConfig();
            }
            return EquipConfig._instance;
        }

        /* internal */ /* var */_equipConfigDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_refreshRateDic: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: EquipConfig;
    }
